﻿using System.Collections.Generic;
using Server.Module;

namespace Server.Business.Player
{
    public static class PlayerManage
    {
        private static Dictionary<long, PlayerData> allPlayerDatas = new Dictionary<long, PlayerData>();

        /// <summary>
        /// 创建玩家
        /// </summary>
        public static void CreatePlayer(long _uid)
        {
            PlayerData playerData = new PlayerData(_uid);
            allPlayerDatas.Add(_uid, playerData);
        }

        /// <summary>
        /// 根据玩家的唯一id获取玩家
        /// </summary>
        /// <param name="_uid"></param>
        /// <returns></returns>
        public static PlayerData GetPlayerDataByUid(long _uid)
        {
            if (allPlayerDatas.ContainsKey(_uid))
                return allPlayerDatas[_uid];
            else
                return null;
        }

        /// <summary>
        /// 根据uid踢人
        /// </summary>
        /// <param name="_uid"></param>
        public static void RemovePLayerByUid(long _uid, string _removeTip)
        {
            if (allPlayerDatas.ContainsKey(_uid))
            {
                //ModuleManager.TcpMessageModule.BreakWebSocket(allPlayerDatas[_uid].WebSocketId, _removeTip);
                allPlayerDatas.Remove(_uid);
            }
        }
    }   
}